﻿using System;
using System.Collections.Generic;
using System.Linq;
using Red.Controls.Diagrams.ViewModels;
using Red.Controls.ViewModels;

namespace Red.Controls.Diagrams.Actions.InteropActions
{
    public class RemoveConnectionsAction : InteropActionBase
    {
        #region Data

        private IEnumerable<ActionConnectionData> _connectionsData;

        #endregion Data

        #region C-tor

        public RemoveConnectionsAction( DiagramViewModel viewModel, DataItem parentObject, IEnumerable<ConnectionViewModel> connections )
        {
            _parentObject = parentObject;
            _viewModel = viewModel;
            _connectionsData = connections.Select( connection => new ActionConnectionData( connection ) ).ToList();
        }

        #endregion C-tor

        #region Public methods

        public void Execute()
        {
            var operationID = Guid.NewGuid().ToString();

            foreach ( var connectionData in _connectionsData )
                RemoveConnectionData( connectionData, operationID );
        }

        #endregion Public methods
    }
}
